//
//  MyFriendTextCell.m
//  FreeTime
//
//  Created by  on 16/9/1.
//  Copyright © 2016年 SRDZ.com. All rights reserved.
//

#import "MyFriendTextCell.h"
#import "Header.h"

@interface MyFriendTextCell (){
    UILabel * titleLbl;
    UIView * bgView;
}

@end

@implementation MyFriendTextCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.dayLbl = [UILabel new];
        _dayLbl.font = [UIFont boldSystemFontOfSize:19];
        _dayLbl.textColor = [UIColor blackColor];
        //        _dayLbl.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_dayLbl];
        
        self.monthLbl = [UILabel new];
        _monthLbl.font = [UIFont boldSystemFontOfSize:14];
        _monthLbl.textColor = [ImageUtil colorWithRgb:0x999999];
        [self.contentView addSubview:_monthLbl];
        bgView = [[UIView alloc] init];
        bgView.backgroundColor = RGB_COLOR(238, 236, 231);
        [self.contentView addSubview:bgView];

        titleLbl = [UILabel new];
        titleLbl.font = FONT(14);
        titleLbl.numberOfLines =0;
        titleLbl.textColor = [ImageUtil colorWithRgb:0x666666];
        [bgView addSubview:titleLbl];
    }
    return self;
}
- (void)bindData:(NSDictionary *)dic indexPath:(NSIndexPath *)indexPath{
    
    bgView.frame = [dic[@"bgViewFrame"] CGRectValue];
    titleLbl.frame = [dic[@"titleFrame"] CGRectValue];
    self.dayLbl.frame = [dic[@"dayFrame"] CGRectValue];
    self.monthLbl.frame = [dic[@"monthFrame"] CGRectValue];
    self.dayLbl.text = @"112";
    self.monthLbl.text = @"333";
    titleLbl.text = dic[@"title"];
}
+ (NSMutableDictionary *)cellFrame:(NSMutableDictionary *)dic indexPath:(NSIndexPath *)indexPath
{
    dic = [MyFriendTextCell turn:dic indexPath:indexPath];
    CGFloat h = [ToolUtil customAutoHeigh:dic[@"title"] width:WindowWidth-90 num:14];
    CGFloat h1 = 0;
    if (h<=80) {
        h1=h;
    }else{
        h1=80;
    }
    CGRect dayFrame = CGRectMake(10, 0, 70, 20);
    CGRect monthFrame = CGRectMake(10, CGRectGetMaxY(dayFrame)+5, 70, 15);
    CGRect bgViewFrame = CGRectMake(80, 0, WindowWidth-90, h1+10);
    CGRect titleFrame = CGRectMake(5, 5, WindowWidth-100, h1);
    CGFloat cellHeight = CGRectGetMaxY(bgViewFrame)+10;
    [dic setObject:[NSValue valueWithCGRect:dayFrame] forKey:@"dayFrame"];
    [dic setObject:[NSValue valueWithCGRect:monthFrame] forKey:@"monthFrame"];
    [dic setObject:[NSValue valueWithCGRect:bgViewFrame] forKey:@"bgViewFrame"];
    [dic setObject:[NSValue valueWithCGRect:titleFrame] forKey:@"titleFrame"];
    [dic setObject:[NSNumber numberWithFloat:cellHeight] forKey:@"cellHeight"];
    return dic;
}
+ (NSMutableDictionary*)turn:(NSMutableDictionary*)dict indexPath:(NSIndexPath *)indexPath{
    return [NSMutableDictionary dictionaryWithDictionary:dict];

}
@end
